<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    
        alert(a);    //function a() {alert(40);}
        var a = 10;  
        alert(a);     //10
        function a() {
            alert(20);
        }
        alert(a);     //10
        var a = 20;
        alert(a);     //20
        function a() {
            alert(40);
        }
        alert(a);     //20
        a();     //报错


        /*
        1.定义
            function a() {alert(40)}
        2.执行
            alert(a);    //函数块  function a() {alert(40)}
            a = 10;


        
        */

    </script>
</body>
</html>